<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        
        <el-col :span="8">
            <el-form-item class="required" label="设备编号" prop="FCATNO">
              <el-input
                v-model="dataForm.FCATNO"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        <el-col :span="8">
            <el-form-item label="设备分类">
              <el-select v-model="dataForm.FITEMTYPE" placeholder="请选择" readonly="true">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="设备类型">
              <el-select v-model="dataForm.FCATTYPE" placeholder="请选择" readonly="true">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="设备名称" prop="FCATNAME" readonly="true">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="设备型号" class="required" prop="FSPEC" readonly="true">
              <el-input
                v-model="dataForm.FSPEC"
                placeholder="请输入"
                clearable
                :disabled="!insertorupdate"
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="单位" prop="FUNIT" readonly="true">
              <el-input
                v-model="dataForm.FUNIT"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="品牌" prop="FBRAND" readonly="true">
              <el-input
                v-model="dataForm.FBRAND"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="使用年限" prop="FUSEYEAR" readonly="true">
              <el-input
                v-model="dataForm.FUSEYEAR"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="电流" prop="FDY" readonly="true">
              <el-input
                v-model="dataForm.FDY"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="最低电压" prop="FLOWDY" readonly="true">
              <el-input
                v-model="dataForm.FLOWDY"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="最高电压" prop="FHEIGHTDY" readonly="true">
              <el-input
                v-model="dataForm.FHEIGHTDY"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item class="required" label="设备图片" prop="FIMAGE" readonly="true">
              <el-input
                v-model="dataForm.FIMAGE"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

   <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="日巡查" name="first">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" width="75"></el-table-column>
          <el-table-column prop="FITEM01" label="巡查项目" width="125"></el-table-column>
          <el-table-column prop="FITEM02" label="巡检内容" ></el-table-column>
          <el-table-column prop="FITEM03" label="巡查结果"></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>
      <el-tab-pane label="月巡查" name="second">
        <el-table :data="list1" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" width="75"></el-table-column>
          <el-table-column prop="FITEM01" label="巡查项目" width="125"></el-table-column>
          <el-table-column prop="FITEM02" label="巡检内容" ></el-table-column>
          <el-table-column prop="FITEM03" label="巡查结果"></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>
      <el-tab-pane label="年巡查" name="third">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" width="75"></el-table-column>
          <el-table-column prop="FITEM01" label="巡查项目" width="125"></el-table-column>
          <el-table-column prop="FITEM02" label="巡检内容" ></el-table-column>
          <el-table-column prop="FITEM03" label="巡查结果"></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
        </el-tab-pane>
      <!-- <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
    </el-tabs>
  </template>
    
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FCATNO :"1003",
          FITEMTYPE:"空调",
          FCATTYPE:"空调",
          FCATNAME:"春兰空调",
          FCONTORL: "101教室",
          FSPEC: "2021-1-A",
          FBRAND: "春兰",
          FUNIT: "台",
          FUSEYEAR: "10",
          FDY: "10",
          FLOWDY: "215",
          FHEIGHTDY:"225",
          FBARCODE:"210038",
          FORDWEEK:"30",
          FIMAGE:"",
          FCHARGETYPE:"小时",
          FCHARGEAMT:0,
          FNOTE: ""
        },
        rules: {
          FCATNO:[
            { required: true, message: '请输入设备编号', trigger: 'blur' },
          ],
          FCATNAME: [
            { required: true, message: '请输入设备名称', trigger: 'blur' },
          ],
          FBRAND: [
            { required: true, message: '请输入设备型号', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FITEM01": "外观检查",
                  "FITEM02": "设备外观是否完好，有无损坏、锈蚀等现象",
                  "FITEM03": "完好,损坏,锈蚀",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FITEM01": "运行状态",
                  "FITEM02": "设备运行是否平稳，有无异响、振动等异常情况",
                  "FITEM03": "平稳,异响,振动",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FITEM01": "电气系统",
                  "FITEM02": "检查电线电缆是否完好，接线是否牢固，电器元件是否正常工作",
                  "FITEM03": "完好,脱线,异常",
                  "FMEMO": ""
                },
                { "FENTRYID":4,
                  "FITEM01": "润滑系统",
                  "FITEM02": "检查设备润滑部位是否缺油，润滑油脂是否清洁、适量",
                  "FITEM03": "平稳,缺油,保洁",
                  "FMEMO": ""
                },
                { "FENTRYID":5,
                  "FITEM01": "安全防护",
                  "FITEM02": "检查设备的安全防护装置是否完好，操作是否灵活",
                  "FITEM03": "完好,异响,振动",
                  "FMEMO": ""
                }],
        list1: [{  "FENTRYID":1,
                  "FITEM01": "外观检查",
                  "FITEM02": "设备外观是否完好，有无损坏、锈蚀等现象",
                  "FITEM03": "完好,损坏,锈蚀",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FITEM01": "运行状态",
                  "FITEM02": "设备运行是否平稳，有无异响、振动等异常情况",
                  "FITEM03": "平稳,异响,振动",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FITEM01": "电气系统",
                  "FITEM02": "检查电线电缆是否完好，接线是否牢固，电器元件是否正常工作",
                  "FITEM03": "完好,脱线,异常",
                  "FMEMO": ""
                }],
          list2: [{"FENTRYID":1,
                  "FITEM01": "运行时间",
                  "FITEM02": "设备今年运行时间",
                  "FITEM03": "",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FITEM01": "保养次数",
                  "FITEM02": "设备今年保养次数",
                  "FITEM03": "",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FITEM01": "维修次数",
                  "FITEM02": "设备今年维修次数",
                  "FITEM03": "",
                  "FMEMO": ""
                },{ "FENTRYID":4,
                  "FITEM01": "润滑系统",
                  "FITEM02": "检查设备润滑部位是否缺油，润滑油脂是否清洁、适量",
                  "FITEM03": "平稳,缺油,保洁",
                  "FMEMO": ""
                },
                { "FENTRYID":5,
                  "FITEM01": "安全防护",
                  "FITEM02": "检查设备的安全防护装置是否完好，操作是否灵活",
                  "FITEM03": "完好,异响,振动",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '10',
          label: '单插'
        }, {
          value: '20',
          label: '双开'
        }, {
          value: '21',
          label: '空调'
        }, {
          value: '22',
          label: '通风柜'
        }, {
          value: '23',
          label: '智能柜'
        },
      ],

        //所属楼层选择数据
        options2: [{
          value: '20E01',
          label: '电器'
        }, {
          value: '20E02',
          label: '空调'
        }, {
          value: '20N01',
          label: '智能柜'
        }, {
          value: '20N02',
          label: '通风柜'
        }],
        
        //所属楼层选择数据
        options3: [{
          value: '20E01',
          label: '普通'
        }, {
          value: '20E02',
          label: '空开'
        }, {
          value: '20N01',
          label: '单火开关'
        }, {
          value: '20N02',
          label: '红外'
        }],

        //所属楼层选择数据
        options4: [{
          value: '1',
          label: '小时'
        }, {
          value: '2',
          label: '每次'
        }],

      };
    },
    created() {
    },
    mounted() { },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>